//Jairo Bonanata 4.179.044-6
//Rodrigo Stecanella 4.388.511-8
//Pedro Osimani 3.963.430-1

package solfinds;

public class Finds {

    String[] hipotesis;
    String[][] congIns;

    Finds() {
        hipotesis = new String[5];
        hipotesis[0] = "0";
        hipotesis[1] = "0";
        hipotesis[2] = "0";
        hipotesis[3] = "0";
        hipotesis[4] = "0";
        congIns = new String[12][5];
        for (int i = 0; i < 12; i++) {
            congIns[i][0] = "Alta";
            congIns[i][1] = "Media";
            if (i < 6) {
                congIns[i][2] = "Matutino";
            } else {
                congIns[i][2] = "Nocturno";
            }
            if (i < 2 || (i > 5 && i < 8)) {
                congIns[i][3] = "Alta";
            } else if ((i > 1 && i < 4) || (i > 7 && i < 10)) {
                congIns[i][3] = "Media";
            } else {
                congIns[i][3] = "Baja";
            }
            if ((i % 2) == 0) {
                congIns[i][4] = "Bueno";
            } else {
                congIns[i][4] = "Malo";
            }
        }
    }

    void appendInstancia(String[] inst) {
        for (int i = 0; i < 5; i++) {
            if (hipotesis[i].equals("0")) {
                hipotesis[i] = inst[i];
            } else if (!hipotesis[i].equals("?") && !hipotesis[i].equals(inst[i])) {
                hipotesis[i] = "?";
            }
        }
    }
    void mostrar (){
        System.out.print("<");
        for (int i = 0; i < 5; i++){
            System.out.print(hipotesis[i]);
            if (i<4)
                System.out.print(",");
        }
        System.out.println(">");
    }
    boolean esConcepto (){
        return  hipotesis[0].equals("Alta") && hipotesis[1].equals("Media") &&
                hipotesis[2].equals("?") && hipotesis[3].equals("?") &&
                hipotesis[4].equals("?");
    }
    String[] generarInstancia(){
        int rnd = randomAcotado (1,congIns.length);
        String [] salida = new String [5];
        salida = congIns[rnd-1];
        congIns = eliminarElementoStr (congIns, rnd-1);
        return salida;
    }
    int randomAcotado (int Min, int Max){
        return ((int)(Math.random()*((Max+1)-Min))+Min);
    }
    String[][] eliminarElementoStr(String[][] mat, int ele){
        int largo = mat.length;
        String[][] salida = new String[largo-1][];
        int j = 0;
        for (int i = 0; i < largo; i++){
            if (i != ele){
                salida[j] = mat[i];
                j++;
            }
        }
        return salida;
    }    
}
